Skip to content

Deprecate cacheClass(), select cache storage internally - #8311

Merged
TomasVotruba merged 3 commits into
mainfrom
claude/deprecate-cache-class-4bavrw
Aug 10, 2026
Merged

Deprecate cacheClass(), select cache storage internally#8311
TomasVotruba merged 3 commits into
mainfrom
claude/deprecate-cache-class-4bavrw

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Aug 6, 2026

Copy link
Copy Markdown
Member

What

Moves the file-vs-memory cache storage decision out of user config and into CacheFactory, and deprecates the public cacheClass() API.

Why

cacheClass() exposed the CacheStorageInterface implementation as a public config knob, but there are only two implementations and only one is ever useful to end users:

  • FileCacheStorage — the real, cross-run cache.
  • MemoryCacheStorage — an in-process array, wiped when the PHP process exits.

A Rector CLI run processes every file once in a single process (hasFileChanged() loads before cacheFile() saves), so memory storage delivers zero cross-invocation benefit — the whole value of the cache is between runs. So cacheClass() was an implementation detail leaked as public API with no valid production use.

How

  • CacheFactory now resolves the storage internally: an explicit cacheClass() still wins, otherwise file cache locally and in-memory cache in CI (where the ephemeral workspace makes writing a cache that is never re-read wasted IO). This is the exact policy that previously lived in config/config.php, just moved behind the factory — behaviour-preserving.
  • RectorConfig::cacheClass() and the withCache(cacheClass:) argument are marked #[Deprecated]. They remain functional for the rare case that needs to force a specific storage — e.g. the e2e cache tests, which force FileCacheStorage so they can verify the persisted cache across two runs even on CI.
  • Internal callers set the parameter directly instead of calling the deprecated method, so PHPStan's deprecation rules stay green.

No new environment variables or config surface. Split out from a combined branch; the FileCacheStorage::save() simplification is #8312.

@TomasVotruba
TomasVotruba force-pushed the claude/deprecate-cache-class-4bavrw branch 2 times, most recently from 8355c2c to b9b3b51 Compare August 6, 2026 21:24
claude and others added 2 commits August 10, 2026 22:32
Move the file-vs-memory cache storage decision into CacheFactory: an explicit
cacheClass() still wins, otherwise file cache is used locally and in-memory
cache in CI, where the ephemeral workspace makes writing a cache that is never
re-read wasted IO. Previously this CI branch lived in config/config.php.

Mark RectorConfig::cacheClass() and the withCache(cacheClass:) argument as
deprecated; they stay functional for the rare case that needs to force a
specific storage (e.g. the e2e cache tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ti6vHRo3xLSHw84rxUw6Lb
@TomasVotruba
TomasVotruba marked this pull request as ready for review August 10, 2026 20:33
The e2e_with_cache workflow was the only consumer of e2eTestRunnerWithCache.php,
applied-rule-removed-node-with-cache/ and timeout-file-not-cached/. They forced
FileCacheStorage via cacheClass() to verify the persisted cache across two runs
on CI; with the storage resolved internally that is no longer possible, so the
workflow and its fixtures go away together.
@TomasVotruba
TomasVotruba force-pushed the claude/deprecate-cache-class-4bavrw branch from b9b3b51 to 63cf914 Compare August 10, 2026 20:42
@TomasVotruba
TomasVotruba enabled auto-merge (squash) August 10, 2026 20:46
@TomasVotruba
TomasVotruba merged commit 8dbd0e1 into main Aug 10, 2026
52 checks passed
@TomasVotruba
TomasVotruba deleted the claude/deprecate-cache-class-4bavrw branch August 10, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants